<!--todo 折线图父组件-->

<template>
    <div class="content">


        <!--循环数据-->
        <!--        <div v-for="(item,index) in userList" :key="index">{{item.wxNick}}</div>-->


        <div class="header">
            <!--总销售额-->
            <sales></sales>
            <!--折线图-->
            <line-chart/>
            <!--            支付记录-->
            <payment></payment>
            <!--进度条-->
            <progress-bar></progress-bar>
        </div>
        <div class="container">
            <sales-trend></sales-trend>
        </div>
        <div class="container-2">
            <search></search>
            <pie-chart></pie-chart>
        </div>
        <!--        底部-->
        <store-door></store-door>
        <!--        版权-->
        <!--        <footer></footer>-->
    </div>

</template>

<script>
    import lineChart from '../views/lineChart' //as 取别名 ,注册子组件时，不要取别名
    import progressBar from '../views/progressBar'
    import sales from '../views/sales'
    import payment from '../views/payment'
    import salesTrend from '../views/salesTrend'
    import search from '../views/search'
    import pieChart from '../views/pieChart'
    import storeDoor from '../views/storeDoor'
    import {getAllUserData, getJsonData, getName} from '../api/test_api'
    /*.. 以当前当前文件为起点，向下寻找文件*/


    export default {
        name: "Analyze",
        components: {
            LineChart: lineChart,
            ProgressBar: progressBar,
            sales: sales,
            payment,
            salesTrend,
            search,
            pieChart,
            storeDoor,
        },

        data() {
            return {
                /*用户数组*/
                userList: []


            }
        },
        created() {
        },

        methods: {

            /*获取所有用户数据*/
            getAll() {
                getAllUserData().then(res => {
                    if (res.status === 200) {
                        let data = res.data;
                        let userList = data.data;
                        // let code = data.code;
                        // let msg = data.msg;
                        let {code, msg} = data
                        this.userList = userList
                        console.log("userList：：", userList)
                        console.log("code：：", code)
                        console.log("msg：：", msg)
                        console.log("this.userList：：", this.userList)

                    } else {
                        console.error("接口调取失败了,请检查：：", res)
                    }
                }).catch(err => {
                    console.error("接口调取失败了：：", err)
                })
            },

            /*获取名字*/
            getUserName() {
                getName("zhangsan").then(res => {
                    if (res.status === 200) {
                        console.info("接口调取：：", res)
                    } else {
                        console.error("接口调取失败了,请检查：：", res)
                    }
                }).catch(err => {
                    console.error("接口调取失败了：：", err)
                })
            },


            getJson() {
                getJsonData().then(res => {
                    console.log("json:::", res)
                }).catch(err => {
                    console.log("err:::", err)
                })
            },


        },

        mounted() {
            // this.getJson()
            // this.getUserName()
            // this.getAll()
        }

    }
</script>

<style scoped>
    p {
        padding: 0;
        margin: 0;
    }

    .content {
        background: #f0f2f5;
        height: 1872px;
        padding: 25px;
    }

    .header {
        display: flex;
    }

    .container-2 {
        display: flex;
        padding: 25px;
        height: 520px;
    }
</style>
